package main

import "strings"

func lengthOfLastWord(s string) int {
	if len(s) == 0 {
		return 0
	}
	s = strings.TrimRight(s, " ")
	i := len(s) - 1
	for ; i >= 0; i-- {
		if s[i] == ' ' {
			break
		}
	}
	return len(s) - i - 1
}

func main() {
	println(lengthOfLastWord("a "))
}
